/**
 * 
 */
package com.roshan.web.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.roshan.web.util.RoarStringUtils;
import com.roshan.web.util.constants.CommonConstants;

/**
 * The Class UserProfile.
 * 
 * @author roshan
 */
@SuppressWarnings("nls")
public class UserProfile implements Serializable {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = 100L;

    /** The user name. */
    private String userName;

    /** The first name. */
    private String firstName;

    /** The last name. */
    private String lastName;

    /** The email. */
    private String email;

    /** The mobile. */
    private String mobile;

    /** The mobile first section. */
    private String mobileFirstSection;

    /** The mobile second section. */
    private String mobileSecondSection;

    /** The mobile third section. */
    private String mobileThirdSection;

    /** The tenant profile uri. */
    private String tenantProfileUri;

    /** The partner profile uri. */
    private String partnerProfileUri;

    /** The passcode. */
    private Passcode passcode = new Passcode();

    /** The confirm passcode. */
    private ConfirmPasscode confirmPasscode = new ConfirmPasscode();

    /** The security question. */
    private String securityQuestion;

    /** The security answer. */
    private String securityAnswer;

    /** The mfa question names. */
    private Map<String, String> mfaQuestionNames;

    /** The mfa question names string. */
    private String mfaQuestionNamesString;

    /** The mfa question builder. */
    private String mfaQuestionBuilder;

    /** The mfa questions. */
    private List<String> mfaQuestions = new ArrayList<String>();

    /** The mfa question and answers. */
    private Map<String, String> mfaQuestionAnswers = new LinkedHashMap<String, String>();

    /** The device types. */
    private List<String> deviceTypes = new ArrayList<String>();

    /** The agree to conditions. */
    private boolean agreeToConditions;

    /** The full name. */
    private String fullName;

    /** The password detail. */
    private PasswordDetail passwordDetail = new PasswordDetail();

    /**
     * Gets the user name.
     * 
     * @return the userName
     */
    public String getUserName() {
        return this.userName;
    }

    /**
     * Sets the user name.
     * 
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * Gets the first name.
     * 
     * @return the firstName
     */
    public String getFirstName() {
        return this.firstName;
    }

    /**
     * Sets the first name.
     * 
     * @param firstName the firstName to set
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Gets the last name.
     * 
     * @return the lastName
     */
    public String getLastName() {
        return this.lastName;
    }

    /**
     * Sets the last name.
     * 
     * @param lastName the lastName to set
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * Gets the email.
     * 
     * @return the email
     */
    public String getEmail() {
        return this.email;
    }

    /**
     * Sets the email.
     * 
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Gets the mobile.
     * 
     * @return the mobile
     */
    public String getMobile() {
        this.mobile = "";
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileFirstSection);
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileSecondSection);
        this.mobile = concatMobileNumberSection(this.mobile, this.mobileThirdSection);
        return this.mobile;
    }

    /**
     * Concat mobile number section.
     */
    private String concatMobileNumberSection(String mobileParam, String section) {

        String mobileNumber = mobileParam;
        if (org.springframework.util.StringUtils.hasText(section)) {
            mobileNumber += section;
        }
        return mobileNumber;
    }

    /**
     * Sets the mobile.
     * 
     * @param mobile the mobile to set
     */
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     * Gets the password.
     * 
     * @return the password
     */
    public String getPassword() {
        return this.passwordDetail.getPassword();
    }

    /**
     * Sets the password.
     * 
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.passwordDetail.setPassword(password);
    }

    /**
     * Gets the confirm password.
     * 
     * @return the confirmPassword
     */
    public String getConfirmPassword() {
        return this.passwordDetail.getConfirmPassword();
    }

    /**
     * Sets the confirm password.
     * 
     * @param confirmPassword the confirmPassword to set
     */
    public void setConfirmPassword(String confirmPassword) {
        this.passwordDetail.setConfirmPassword(confirmPassword);
    }

    /**
     * Gets the passcode.
     * 
     * @return the passcode
     */
    public Passcode getPasscode() {
        return this.passcode;
    }

    /**
     * Sets the passcode.
     * 
     * @param passcode the passcode to set
     */
    public void setPasscode(Passcode passcode) {
        this.passcode = passcode;
    }

    /**
     * Gets the confirm passcode.
     * 
     * @return the confirmPasscode
     */
    public ConfirmPasscode getConfirmPasscode() {
        return this.confirmPasscode;
    }

    /**
     * Sets the confirm passcode.
     * 
     * @param confirmPasscode the confirmPasscode to set
     */
    public void setConfirmPasscode(ConfirmPasscode confirmPasscode) {
        this.confirmPasscode = confirmPasscode;
    }

    /**
     * Gets the security question.
     * 
     * @return the securityQuestion
     */
    public String getSecurityQuestion() {
        return this.securityQuestion;
    }

    /**
     * Sets the security question.
     * 
     * @param securityQuestion the securityQuestion to set
     */
    public void setSecurityQuestion(String securityQuestion) {
        this.securityQuestion = securityQuestion;
    }

    /**
     * Gets the security answer.
     * 
     * @return the securityAnswer
     */
    public String getSecurityAnswer() {
        return this.securityAnswer;
    }

    /**
     * Sets the security answer.
     * 
     * @param securityAnswer the securityAnswer to set
     */
    public void setSecurityAnswer(String securityAnswer) {
        this.securityAnswer = securityAnswer;
    }

    /**
     * Gets the mfa question names.
     * 
     * @return the mfaQuestionNames
     */
    public Map<String, String> getMfaQuestionNames() {
        return this.mfaQuestionNames;
    }

    /**
     * Sets the mfa question names.
     * 
     * @param mfaQuestionNames the new mfa question names
     */
    public void setMfaQuestionNames(String mfaQuestionNames) {
        this.mfaQuestionNames = RoarStringUtils.stringToMap(mfaQuestionNames);
    }

    /**
     * Gets the mfa question builder.
     * 
     * @return the mfaQuestionBuilder
     */
    public String getMfaQuestionBuilder() {
        return this.mfaQuestionBuilder;
    }

    /**
     * Sets the mfa question builder.
     * 
     * @param mfaQuestionBuilder the mfaQuestionBuilder to set
     */
    public void setMfaQuestionBuilder(String mfaQuestionBuilder) {
        this.mfaQuestionBuilder = mfaQuestionBuilder;
    }

    /**
     * Gets the mfa questions.
     * 
     * @return the mfaQuestions
     */
    public List<String> getMfaQuestions() {
        return this.mfaQuestions;
    }

    /**
     * Sets the mfa questions.
     * 
     * @param mfaQuestions the mfaQuestions to set
     */
    public void setMfaQuestions(List<String> mfaQuestions) {
        this.mfaQuestions = mfaQuestions;
    }

    /**
     * Gets the tenant profile uri.
     * 
     * @return the tenantProfileUri
     */
    public String getTenantProfileUri() {
        return this.tenantProfileUri;
    }

    /**
     * Sets the tenant profile uri.
     * 
     * @param tenantProfileUri the tenantProfileUri to set
     */
    public void setTenantProfileUri(String tenantProfileUri) {
        this.tenantProfileUri = tenantProfileUri;
    }

    /**
     * Gets the partner profile uri.
     * 
     * @return the partnerProfileUri
     */
    public String getPartnerProfileUri() {
        return this.partnerProfileUri;
    }

    /**
     * Sets the partner profile uri.
     * 
     * @param partnerProfileUri the partnerProfileUri to set
     */
    public void setPartnerProfileUri(String partnerProfileUri) {
        this.partnerProfileUri = partnerProfileUri;
    }

    /**
     * Gets the mfa question answers.
     * 
     * @return the mfaQuestionAnswers
     */
    public Map<String, String> getMfaQuestionAnswers() {
        return this.mfaQuestionAnswers;
    }

    /**
     * Sets the mfa question answers.
     * 
     * @param mfaQuestionAnswers the mfaQuestionAnswers to set
     */
    public void setMfaQuestionAnswers(Map<String, String> mfaQuestionAnswers) {
        this.mfaQuestionAnswers = mfaQuestionAnswers;
    }

    /**
     * Gets the mfa question names string.
     * 
     * @return the mfaQuestionNamesString
     */
    public String getMfaQuestionNamesString() {
        return this.mfaQuestionNamesString;
    }

    /**
     * Sets the mfa question names string.
     * 
     * @param mfaQuestionNamesString the mfaQuestionNamesString to set
     */
    public void setMfaQuestionNamesString(String mfaQuestionNamesString) {
        this.mfaQuestionNamesString = mfaQuestionNamesString;
    }

    /**
     * Sets the mfa question names.
     * 
     * @param mfaQuestionNames the mfaQuestionNames to set
     */
    public void setMfaQuestionNames(Map<String, String> mfaQuestionNames) {
        this.mfaQuestionNames = mfaQuestionNames;
    }

    /**
     * Gets the device types.
     * 
     * @return the deviceTypes
     */
    public List<String> getDeviceTypes() {
        return this.deviceTypes;
    }

    /**
     * Sets the device types.
     * 
     * @param deviceTypes the deviceTypes to set
     */
    public void setDeviceTypes(List<String> deviceTypes) {
        this.deviceTypes = deviceTypes;
    }

    /**
     * Gets the mobile first section.
     * 
     * @return the mobileFirstSection
     */
    public String getMobileFirstSection() {
        return this.mobileFirstSection;
    }

    /**
     * Sets the mobile first section.
     * 
     * @param mobileFirstSection the mobileFirstSection to set
     */
    public void setMobileFirstSection(String mobileFirstSection) {
        this.mobileFirstSection = mobileFirstSection;
    }

    /**
     * Gets the mobile second section.
     * 
     * @return the mobileSecondSection
     */
    public String getMobileSecondSection() {
        return this.mobileSecondSection;
    }

    /**
     * Sets the mobile second section.
     * 
     * @param mobileSecondSection the mobileSecondSection to set
     */
    public void setMobileSecondSection(String mobileSecondSection) {
        this.mobileSecondSection = mobileSecondSection;
    }

    /**
     * Gets the mobile third section.
     * 
     * @return the mobileThirdSection
     */
    public String getMobileThirdSection() {
        return this.mobileThirdSection;
    }

    /**
     * Sets the mobile third section.
     * 
     * @param mobileThirdSection the mobileThirdSection to set
     */
    public void setMobileThirdSection(String mobileThirdSection) {
        this.mobileThirdSection = mobileThirdSection;
    }

    /**
     * Checks if is agree to conditions.
     * 
     * @return true, if is agree to conditions
     */
    public boolean isAgreeToConditions() {
        return agreeToConditions;
    }

    /**
     * Sets the agree to conditions.
     * 
     * @param agreeToConditions the new agree to conditions
     */
    public void setAgreeToConditions(boolean agreeToConditions) {
        this.agreeToConditions = agreeToConditions;
    }

    /**
     * Gets the full name.
     * 
     * @return the full name
     */
    public String getFullName() {
        return fullName;
    }

    /**
     * Sets the full name.
     * 
     * @param fullName the new full name
     */
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    /**
     * Sets the password detail.
     * 
     * @param passwordDetail the new password detail
     */
    public void setPasswordDetail(PasswordDetail passwordDetail) {
        this.passwordDetail = passwordDetail;
    }

    /**
     * Split full name in to the first name and last name.
     */
    public void splitFullName() {
        this.lastName = CommonConstants.EMPTY;
        String[] nameParts = this.fullName.split(CommonConstants.SPACE);
        this.firstName = nameParts[0].trim();
        for (int i = 1; i < nameParts.length; i++) {
            if (!CommonConstants.EMPTY.equals(nameParts[i])) {
                this.lastName = this.lastName
                        + ((CommonConstants.EMPTY.equals(this.lastName)) ? nameParts[i] : CommonConstants.SPACE
                                + nameParts[i]);
            }
        }

        this.lastName = this.lastName.trim();
    }
}
